﻿@model Shop.User.Models.UsersInfo
@{
    ViewBag.Title = "用户注册";
    Layout = "~/Views/Home/_HomeLayout.cshtml";
}
    <link href="~/bootstrapvalidator-master/dist/css/bootstrapValidator.min.css" rel="stylesheet" />
    <script src="~/bootstrapvalidator-master/dist/js/bootstrapValidator.min.js"></script>

    @using (Html.BeginForm("UsersReg", "User", FormMethod.Post, new { @class = "form-horizontal" ,@id= "defaultForm"}))
    {
        <div class="container">
            <div class="row">
                <div class="col-lg-8 col-lg-offset-2">
                    <div class="page-header">
                        <h2>用户注册</h2>
                    </div>
                        <div class="form-group">
                            <label class="col-lg-3 control-label">用户名</label>
                            <div class="col-lg-5">
                                @Html.TextBoxFor(Model => Model.UName, htmlAttributes: new { @class = "form-control",@name="UName", @placeholder = "用户名" })
                                <span style="color:red"> @Html.ValidationMessageFor(Model => Model.UName)</span>
                            </div>
                        </div>
                        
                    <div class="form-group">
                        <label class="col-lg-3 control-label">性别</label>
                        <div class="col-lg-5">
                            @Html.RadioButtonFor(Model => Model.Sex, 1, htmlAttributes: new { @name = "Sex" })男 @Html.RadioButtonFor(Model => Model.Sex, 0, htmlAttributes: new { @name = "Sex" })女
                        <span class="TipInfo"> @Html.ValidationMessageFor(Model => Model.Sex)</span>
                        </div>
                    </div>
                        
                        <div class="form-group">
                            <label class="col-lg-3 control-label">密码</label>
                            <div class="col-lg-5">
                                @Html.PasswordFor(Model => Model.UPass, htmlAttributes: new { @class = "form-control", @name = "UPass", @placeholder = "密码" })
                                <span style="color:red"> @Html.ValidationMessageFor(Model => Model.UPass)</span>
                                @*<input type="password" class="form-control" name="password" />*@
                            </div>
                        </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label">确认密码</label>
                        <div class="col-lg-5">
                            <input type="password" class="form-control" name="truepassword"  placeholder = "确认密码"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label">邮箱</label>
                        <div class="col-lg-5">
                            @Html.TextBoxFor(Model => Model.Email, htmlAttributes: new { @class = "form-control",@name = "Email", @placeholder = "邮箱号" })
                            <span style="color:red"> @Html.ValidationMessageFor(Model => Model.Email)</span>
                            @*<input type="text" class="form-control" name="email" />*@
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-3 control-label">电话</label>
                        <div class="col-lg-5">
                            @Html.TextBoxFor(Model => Model.Tel, htmlAttributes: new { @class = "form-control", @name = "Tel", @placeholder = "电话" })
                            <span style="color:red"> @Html.ValidationMessageFor(Model => Model.Tel)</span>
                            @*<input type="text" class="form-control" name="Tel" />*@
                        </div>
                    </div>
                        <div class="form-group">
                            <div class="col-lg-3"></div>
                            <div class="col-lg-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                            <div class="col-lg-3">
                                <button type="reset" class="btn btn-primary">重置</button>
                            </div>
                        </div>
                    <div class="form-group" style="color:red">
                        @ViewBag.TS
                    </div>
                </div>
            </div>
        </div>
    }
<script type="text/javascript">
$(document).ready(function() {
    $('#defaultForm')
        .bootstrapValidator({
            container: 'tooltip',
            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'glyphicon glyphicon-ok',
                invalid: 'glyphicon glyphicon-remove',
                validating: 'glyphicon glyphicon-refresh'
            },
            fields: {
                UName: {
                    message: 'The username is not valid',
                    validators: {
                        notEmpty: {
                            message: '用户名不能为空'
                        },
                        stringLength: {
                            min: 6,
                            max: 30,
                            message: '用户名字必须基于6-30之间'
                        },
                        regexp: {
                            regexp: /^[a-zA-Z0-9_\.]+$/,
                            message: '用户名只能包含字母，数字，点和下划线'
                        }
                    }
                },
                Sex: {
                    validators: {
                        notEmpty: {
                            message: '请选择性别'
                        }
                    }
                },
                Tel: {
                    message: 'The username is not valid',
                    validators: {
                        notEmpty: {
                            message: '电话不能为空'
                        },
                        stringLength: {
                            min: 11,
                            max: 11,
                            message: '电话必须是11位'
                        },
                        regexp: {
                            regexp: /^[0-9]+$/,
                            message: '电话只能是数字'
                        }
                    }
                },
                Email: {
                    validators: {
                        notEmpty: {
                            message: '电子邮件地址是必需的，不能为空'
                        },
                        emailAddress: {
                            message: '输入不是一个有效的电子邮件地址'
                        }
                    }
                },
                truepassword: {
                    validators: {
                        notEmpty: {
                            message: '确认密码是必需的，不能为空'
                        }
                    }
                },
                UPass: {
                    validators: {
                        notEmpty: {
                            message: '密码是必需的，不能为空'
                        }
                    }
                }
            }
        })
               
});
</script>
